home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Stuff / 3D_Reality / 3D_Reality_API / Examples / Quadric / QuadricInspector.m < prev   
Encoding:
Text File  |  1992-10-25  |  2.9 KB  |  122 lines

  1. #import <3dreality_api.h>
  2.  
  3. @implementation QuadricInspector
  4. - loadShape:(Shape *)shape inView:(Camera *)camera
  5. {
  6.     if (shape) {
  7.     [super loadShape:shape inView:camera]; 
  8.     if ([shape isKindOf:[Quadric class]]) {
  9.         if (radiusSlider)[radiusSlider setFloatValue:
  10.                 [(Quadric *)shape radius]*worldScale];
  11.         if(thetaMaxSlider)[thetaMaxSlider setFloatValue:
  12.                 [(Quadric *)shape thetaMax]];
  13.         if(zMinSlider)[zMinSlider setFloatValue:
  14.                 [(Quadric *)shape zMin]*worldScale];
  15.         if (zMaxSlider)[zMaxSlider setFloatValue:
  16.                 [(Quadric *)shape zMax]*worldScale];
  17.     }
  18.     }
  19.     return self;
  20. }
  21.  
  22. - rescaleSliders:(float)value
  23. {
  24.     [self rescaleSlider:radiusSlider factorBy:value];
  25.     [self rescaleSlider:zMinSlider factorBy:value];
  26.     [self rescaleSlider:zMaxSlider factorBy:value];
  27.     return self;
  28. }
  29.  
  30. - changeRadius:sender
  31. {
  32.     Shape *shape = [self selectedShape];
  33.     if (shape && [shape isKindOf:[Quadric class]]) {
  34.     RtFloat value = [sender floatValue]/worldScale;
  35.     [(Quadric *)shape setRadius:&value];
  36.     [self displayChanges];
  37.     }
  38.     return self;
  39. }
  40.  
  41. - changeThetaMax:sender
  42. {
  43.     Shape *shape = [self selectedShape];
  44.     if (shape && [shape isKindOf:[Quadric class]]) {
  45.     RtFloat value = [sender floatValue];
  46.     [(Quadric *)shape setThetaMax:&value];
  47.     [self displayChanges];
  48.     }
  49.     return self;
  50. }
  51.  
  52. - changeZMin:sender
  53. {
  54.     Shape *shape = [self selectedShape];
  55.     if (shape && [shape isKindOf:[Quadric class]]) {
  56.     RtFloat value = [sender floatValue]/worldScale;
  57.     [(Quadric *)shape setZMin:&value];
  58.     [self displayChanges];
  59.     }
  60.     return self;
  61. }
  62.  
  63. - changeZMax:sender
  64. {
  65.     Shape *shape = [self selectedShape];
  66.     if (shape && [shape isKindOf:[Quadric class]]) {
  67.     RtFloat value = [sender floatValue]/worldScale;
  68.     [(Quadric *)shape setZMax:&value];
  69.     [self displayChanges];
  70.     }
  71.     return self;
  72. }
  73.  
  74. - setRadiusSlider:anObject    
  75. {
  76.     radiusSlider = anObject;
  77.  
  78.     [anObject setUpTarget:self action:@selector(changeRadius:)];
  79.     [anObject setAltStep:.005 whole:NO default:.025];
  80.     [anObject setMax:.5 allowHigher:YES min:0. allowLower:YES];
  81.     [anObject setFloatValue:.025];
  82.  
  83.     return self;
  84. }
  85.  
  86. - setThetaMaxSlider:anObject    
  87. {
  88.     thetaMaxSlider = anObject;
  89.  
  90.     [anObject setUpTarget:self action:@selector(changeThetaMax:)];
  91.     [anObject setAltStep:5 whole:YES default:360];
  92.     [anObject setMax:360 allowHigher:NO min:0. allowLower:YES];
  93.     [anObject setFloatValue:360.];
  94.  
  95.     return self;
  96. }
  97.  
  98. - setZMinSlider:anObject    
  99. {
  100.     zMinSlider = anObject;
  101.  
  102.     [anObject setUpTarget:self action:@selector(changeZMin:)];
  103.     [anObject setAltStep:.01 whole:NO default:.05];
  104.     [anObject setMax:.2 allowHigher:YES min:0. allowLower:YES];
  105.     [anObject setFloatValue:.025];
  106.  
  107.     return self;
  108. }
  109.  
  110. - setZMaxSlider:anObject    
  111. {
  112.     zMaxSlider = anObject;
  113.  
  114.     [anObject setUpTarget:self action:@selector(changeZMax:)];
  115.     [anObject setAltStep:.01 whole:NO default:.05];
  116.     [anObject setMax:.2 allowHigher:YES min:0. allowLower:YES];
  117.     [anObject setFloatValue:.05];
  118.  
  119.     return self;
  120. }
  121. @end
  122.